package com.suredy.app.porject.service;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import com.suredy.app.porject.model.ContractOpLog;
import com.suredy.core.service.BaseSrvWithEntity;

@Service
public class ContractOpLogSrv extends BaseSrvWithEntity<ContractOpLog> {

	public ContractOpLogSrv() {
		this.addAnDefOrder("time", true);
	}

	@Override
	public DetachedCriteria getDc(ContractOpLog t) {
		DetachedCriteria dc = super.getDc(t);

		if (t == null)
			return dc;

		if (!StringUtils.isBlank(t.getId())) {
			dc.add(Restrictions.eq("id", t.getId()));
		}
		if (t.getOp() != null) {
			dc.add(Restrictions.eq("op", t.getOp()));
		}
		if (!StringUtils.isBlank(t.getOper())) {
			dc.add(Restrictions.eq("oper", t.getOper()));
		}

		return dc;
	}

}
